package com.nf;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 　　* @description: TODO
 * 　　* @param
 * 　　* @return
 * 　　* @throws
 * 　　* @author Administrator
 * 　　* @date $ $
 */
public class MiniDbUtils {
    public static void close(Connection connection) throws SQLException {
        if (connection != null) {
            connection.close();
        }
    }

    public static void close(ResultSet resultSet) throws SQLException {
        if (resultSet != null) {
            resultSet.close();
        }
    }

    public static void close(Statement statement) throws SQLException {
        if (statement != null) {
            statement.close();
        }
    }

    public static void closeQuietly(Connection connection) {
        try {
            close(connection);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

    public static void closeQuietly(ResultSet resultSet) {
        try {
            close(resultSet);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

    public static void closeQuietly(Statement statement) {
        try {
            close(statement);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

    public static void closeQuietly(Connection connection, Statement statement, ResultSet resultSet) {
        try {
            closeQuietly(resultSet);
        } finally {
            try {
                closeQuietly(statement);
            } finally {
                closeQuietly(connection);
            }
        }
    }
}
